package com.example.keli.ui.my.bindinfo;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.example.keli.R;
import com.example.keli.base.BaseActivity;
import com.example.keli.base.app.C;
import com.example.keli.base.utils.StringUtils;
import com.example.keli.ui.my.H5Activity;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * description 安全信息
 * created by jerry on 2019/3/18.
 */
public class SafeInfoActivity extends BaseActivity {

    @BindView(R.id.tv_phone)
    TextView tvPhone;
    private String mPhone;

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void bindSuccess(String event) {
        if (C.EVENT.UPDATE_USERINFO.equals(event)) {
            finish();
        }
    }

    public static void start(Context context, String phone) {
        Intent intent = new Intent(context, SafeInfoActivity.class);
        intent.putExtra("phone", phone);
        context.startActivity(intent);
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_safe_info;
    }

    @Override
    protected void bindData() {
        EventBus.getDefault().register(this);
        mPhone = getIntent().getStringExtra("phone");
        if (!TextUtils.isEmpty(mPhone)){
            tvPhone.setText(StringUtils.dealPhoneNumber(mPhone));
        }
        abTitle.setText("绑定手机");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @OnClick(R.id.rl_bind)
    public void onViewClicked() {
//        EditBindActivity.start(this, mPhone);
        toActivity(VerifyNumberActivity.class);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
